var QQMapWX = require('../../libs/qqmap-wx-jssdk');
var qqmapsdk;
Page({
  data: {
    count:1,
    longitude: 112.682482,
    latitude: 28.05964,
    markers: [{
        id: 1,
        longitude: 112.682482,
        latitude: 28.05964,
        name: '腾讯',
        alpha:0.75,
        width:15,
        height:25

      },
      {
        id: 2,
        longitude: 112.682482,
        latitude: 28.05964,
        name: '腾讯',
        width:15,
        height:25,
        callout: {

          content: "2:30，陈某自驾从上海经高速来长\n当日16:05-17:45，抵达长韶娄高速花明楼服务区停留\n期间在服务区上洗手间",
          borderRadius: 15,
          padding: 10,
          display: 'BYCLICK',
          fontSize: 15,
          textAlign: "center",
          anchorX: -10
        },
      },
      {
        id: 3,
        longitude: 112.351916,
        latitude: 27.978156,
        name: '终点',
        width:15,
        height:25,
        callout: {
          content: "18:05，经长韶娄高速灰汤收费站下高速\n后至宁乡市集中隔离酒店，纳入集中隔离管控。",
          borderRadius: 15,
          padding: 10,
          display: 'BYCLICK',
          fontSize: 15,
          textAlign: "center",
          anchorX: -10
        },
      },
    ],
   
    polyline: [{
      points: [{
          longitude: 112.682482,
          latitude: 28.05964
        },
        {
          longitude: 112.677407,
          latitude: 28.059345
        },
        {
          longitude: 112.670266,
          latitude: 28.058213
        },
        {
          longitude: 112.659782,
          latitude: 28.055647
        },
        {
          longitude: 112.655704,
          latitude: 28.054994
        },
        {
          longitude: 112.650009,
          latitude: 28.055424
        },
        {
          longitude: 112.645613,
          latitude: 28.056065
        },
        {
          longitude: 112.639867,
          latitude: 28.05638
        },
        {
          longitude: 112.621047,
          latitude: 28.055137
        },
        {
          longitude: 112.617847,
          latitude: 28.054297
        },
        {
          longitude: 112.605917,
          latitude: 28.048113
        },
        {
          longitude: 112.594413,
          latitude: 28.042169
        },
        {
          longitude: 112.580184,
          latitude: 28.037706
        },
        {
          longitude: 112.565667,
          latitude: 28.033529
        },
        {
          longitude: 112.55053,
          latitude: 28.029017
        },
        {
          longitude: 112.546595,
          latitude: 28.027359
        },
        {
          longitude: 112.540613,
          latitude: 28.023293
        },
        {
          longitude: 112.533911,
          latitude: 28.018367
        },
        {
          longitude: 112.53021,
          latitude: 28.015624
        },
        {
          longitude: 112.529348,
          latitude: 28.01529
        },
        {
          longitude: 112.526474,
          latitude: 28.015242
        },
        {
          longitude: 112.521569,
          latitude: 28.016533
        },
        {
          longitude: 112.519647,
          latitude: 28.016358
        },
        {
          longitude: 112.516862,
          latitude: 28.015114
        },
        {
          longitude: 112.51388,
          latitude: 28.013328
        },
        {
          longitude: 112.50964,
          latitude: 28.012005
        },
        {
          longitude: 112.508328,
          latitude: 28.011423
        },
        {
          longitude: 112.506424,
          latitude: 28.009924
        },
        {
          longitude: 112.503514,
          latitude: 28.007325
        },
        {
          longitude: 112.501843,
          latitude: 28.006575
        },
        {
          longitude: 112.502579,
          latitude: 28.006822
        },
        {
          longitude: 112.50098,
          latitude: 28.006376
        },
        {
          longitude: 112.50098,
          latitude: 28.006376
        },
        {
          longitude: 112.497045,
          latitude: 28.006663
        },
        {
          longitude: 112.494494,
          latitude: 28.00679
        },
        {
          longitude: 112.491152,
          latitude: 28.006152
        },
        {
          longitude: 112.488026,
          latitude: 28.004318
        },
        {
          longitude: 112.481073,
          latitude: 27.999917
        },
        {
          longitude: 112.476887,
          latitude: 27.997732
        },
        {
          longitude: 112.473581,
          latitude: 27.997317
        },
        {
          longitude: 112.470904,
          latitude: 27.997708
        },
        {
          longitude: 112.468461,
          latitude: 27.998362
        },
        {
          longitude: 112.466072,
          latitude: 27.998689
        },

        {
          longitude: 112.46282,
          latitude: 27.998282
        },
        {
          longitude: 112.456766,
          latitude: 27.996369
        },
        {
          longitude: 112.452795,
          latitude: 27.995141
        },
        {
          longitude: 112.448932,
          latitude: 27.994503
        },
        {
          longitude: 112.442572,
          latitude: 27.994192
        },

        {
          longitude: 112.436823,
          latitude: 27.992884
        },
        {
          longitude: 112.429978,
          latitude: 27.991194
        },
        {
          longitude: 112.422827,
          latitude: 27.989503
        },
        {
          longitude: 112.41379,
          latitude: 27.987286
        },
        {
          longitude: 112.408239,
          latitude: 27.985978
        },
        {
          longitude: 112.402274,
          latitude: 27.984989
        },
        {
          longitude: 112.397836,
          latitude: 27.98459
        },
        {
          longitude: 112.391117,
          latitude: 27.984702
        },
        {
          longitude: 112.385511,
          latitude: 27.985053
        },
        {
          longitude: 112.383481,
          latitude: 27.985005
        },

        {
          longitude: 112.382098,
          latitude: 27.984686
        },
        {
          longitude: 112.381164,
          latitude: 27.984559
        },
        {
          longitude: 112.376852,
          latitude: 27.98223
        },
        {
          longitude: 112.375361,
          latitude: 27.980715
        },
        {
          longitude: 112.373555,
          latitude: 27.978905
        },
        {
          longitude: 112.371183,
          latitude: 27.977469
        },
        {
          longitude: 112.367572,
          latitude: 27.976432
        },
        {
          longitude: 112.353029,
          latitude: 27.975371
        },
        {
          longitude: 112.351916,
          latitude: 27.978156
        },
      ],
      width: 4,
      color: "#3875FF",
      borderColor: "#38a9FF",
      borderWidth: 2



    }],


    multiArray: [
      ['长沙市', '湘潭市', '岳阳市', '常德市', '张家界市', '益阳市'],
      ['病例一'],
      ['4月22日']
    ],
    objectMultiArray: [
      [{
          id: 0,
          name: '长沙市'
        },
        {
          id: 1,
          name: '湘潭市'
        },
        {
          id: 2,
          name: '岳阳市'
        },
        {
          id: 3,
          name: '常德市'
        },
        {
          id: 4,
          name: '张家界市'
        },
        {
          id: 5,
          name: '益阳市'
        }
      ],
      [{
          id: 0,
          name: '病例一'
        }

      ],
      [{
        id: 0,
        name: '4月22日'
      }]
    ],
    multiIndex: [0, 0, 0],
  },

  onReady: function (e) {
    //创建 map 上下文 MapContext 对象。
    this.mapCtx = wx.createMapContext('myMap')
  },
  moveAlong: function (e) {
    this.mapCtx.moveAlong({
      markerId: 1,
      path: this.data.polyline[0].points,
      duration: 3000,
      autoRotate:false
    })


  },
  showInfo1:function (e) {
    if(this.data.count<2)
    return
    console.log("上一条" + this.data.count)
    this.setData({
      count: this.data.count -1,
    })
    this.setData({
      ['markers[' + this.data.count + '].callout.display']: 'BYCLICK',
    })
    var temp=this.data.count-1
    this.setData({
      ['markers[' + temp + '].callout.display']: 'ALWAYS',
    })
  

  },




  showInfo: function (e) {
    if(this.data.count>2)
    return;
    console.log("下一条" + this.data.count)
    if (this.data.count > 1)
    {  
        var temp=this.data.count-1
        this.setData({
        ['markers[' + temp + '].callout.display']: 'BYCLICK',
      })
    }


    this.setData({
      ['markers[' + this.data.count + '].callout.display']: 'ALWAYS',
      count: this.data.count + 1
    })

  },




//更改地区选择
  bindMultiPickerChange: function (e) {
    console.log('picker发送选择改变，携带值为', e.detail.value)
    this.setData({
      multiIndex: e.detail.value
    })
  },
  //修改地区时,文字变化
  bindMultiPickerColumnChange: function (e) {
    console.log('修改的列为', e.detail.column, '，值为', e.detail.value);
    var data = {
      multiArray: this.data.multiArray,
      multiIndex: this.data.multiIndex
    };
    data.multiIndex[e.detail.column] = e.detail.value;
    switch (e.detail.column) {
      case 0:
        switch (data.multiIndex[0]) {
          case 0:
            data.multiArray[1] = ['病例一'];
            data.multiArray[2] = ['4月22日'];
            break;
          case 1:
            data.multiArray[1] = ['密接1'];
            data.multiArray[2] = ['3月16日'];
            break;
          case 2:
            data.multiArray[1] = ['该地区暂无病例'];
            data.multiArray[2] = [''];
            wx.showToast({
              title: '该地区暂无病例',
              icon: 'error',
              duration: 2000
            })
            break;
          case 3:
            data.multiArray[1] = ['该地区暂无病例'];
            data.multiArray[2] = [''];
            wx.showToast({
              title: '该地区暂无病例',
              icon: 'error',
              duration: 2000
            })
            break;
          case 4:
            data.multiArray[1] = ['该地区暂无病例'];
            data.multiArray[2] = [''];
            wx.showToast({
              title: '该地区暂无病例',
              icon: 'error',
              duration: 1000,
            })
            setInterval(() => {
              wx.hideToast({
                success: (res) => {},
              })
            }, 5000);
            
            break;
          case 5:
            data.multiArray[1] = ['该地区暂无病例'];
            data.multiArray[2] = [''];
            wx.showToast({
              title: '该地区暂无病例',
              icon: 'error',
              duration: 1000,
            })
            setInterval(() => {
              wx.hideToast({
                success: (res) => {},
              })
            }, 5000);
            break

        }
        data.multiIndex[1] = 0;
        data.multiIndex[2] = 0;
        break;
      case 1:
        switch (data.multiIndex[0]) {
          case 0:
            switch (data.multiIndex[1]) {
              case 0:
                data.multiArray[2] = ['病例一'];
                break;

            }
            break;
          case 1:
            switch (data.multiIndex[1]) {
              case 0:
                data.multiArray[2] = ['密接一'];
                break;
            }
            case 2:
              wx.showToast({
                title: '该地区暂无病例',
                icon: 'error',
                duration: 2000
              })
            case 3:
            case 4:
            case 5:
              break;
        }
        data.multiIndex[2] = 0;
        console.log(data.multiIndex);
        break;
    }
    this.setData(data);
  },
})
